package com.singfan.script.importdata;

import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;

/**
 * Author: hansonghe
 * Date: 2015-08-19 16:42
 * Desc:
 */
public abstract class SheetParser {
    protected XSSFSheet currentSheet;

    public void parse(XSSFSheet sheet) {
        currentSheet = sheet;
        XSSFRow row;
        int rowCount = 0;
        for (int rowIndex = 3; (row = sheet.getRow(rowIndex)) != null; ++rowIndex) {
            insertData(row);
            rowCount++;
        }

        System.out.println(sheet.getSheetName() + " " + rowCount + " data import successful !");
    }

    protected abstract void insertData(XSSFRow row);
}
